'use strict';

/**
 * @ngdoc directive
 * @name App.directive:fullscreen
 * @description
 * # fullscreen
 */
angular.module('App')
/**
 * Simple directive to check password equality
 *
 * usage:
 * <input type="password" ng-model="password" password-match="password2"/>
 * <input type="password" ng-model="password2"/>
 */
.directive('passwordMatch', function () {
  return {
    restrict: 'A',
    scope: false,
    require: 'ngModel',
    link: function (scope, elem, attrs, ngModelCtrl) {
      var checker = function () {
        return scope.$eval(attrs.ngModel) === scope.$eval(attrs.passwordMatch);
      };
      scope.$watch(checker, function (pwdMatch) {
        ngModelCtrl.$setValidity('match', pwdMatch);
      });
    }
  };
})
